<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/14
 * Time: 12:15
 */
$client = new swoole_client(SWOOLE_SOCK_TCP);
if(!$client->connect('127.0.0.1', 9501)){
    echo "connect failed!";
    exit;
}
// php cli 常量
fwrite(STDOUT, "请输入消息：");
$msg = trim(fgets(STDIN));
//给tcp server 发送数据
$client->send($msg);
//接收tcp server返回的数据
$result = $client->recv();
echo $result . PHP_EOL;